import request from '@/utils/request'

// 获取文章列表
export function getArticleList(params: any) {
  return request({
    url: '/articles',
    method: 'get',
    params
  })
}

// 获取文章详情
export function getArticle(id: number) {
  return request({
    url: `/articles/${id}`,
    method: 'get'
  })
}

// 新增文章
export function addArticle(data: any) {
  return request({
    url: '/articles',
    method: 'post',
    data
  })
}

// 更新文章
export function updateArticle(id: number, data: any) {
  return request({
    url: `/articles/${id}`,
    method: 'put',
    data
  })
}

// 删除文章
export function deleteArticle(id: number) {
  return request({
    url: `/articles/${id}`,
    method: 'delete'
  })
}

// 更新文章排序
export function updateArticleOrder(id: number, orderNum: number) {
  return request({
    url: `/articles/${id}/order`,
    method: 'put',
    params: { orderNum }
  })
}